package com.xuecheng.content.convert;

import com.xuecheng.api.content.model.TeachplanDTO;
import com.xuecheng.api.content.model.dot.CourseBaseDTO;
import com.xuecheng.api.content.model.vo.CourseBaseVO;
import com.xuecheng.api.content.model.vo.TeachplanVO;
import com.xuecheng.content.entity.CourseBase;
import com.xuecheng.content.entity.Teachplan;
import com.xuecheng.content.entity.ext.TeachplanNode;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * <p>
 * 对象属性转换器：
 * PS：将MapStruct依赖添加到工程中
 * 1.创建一个接口并在类上添加 @Mapper 注解
 * 2.在接口通过MapStruct的api创建出接口的实例对象
 * 3.转换方法
 * 传入参数、传出参数
 * 将传入参数里的数据会赋值给传出参数
 * <p>
 * 特点：
 * 1.对象中的属性转换数据时，默认情况下将两个对象中的同属性名进行赋值操作
 *
 * </p>
 *
 * @Description:
 */
@Mapper
public interface TeanchplanConvert {
    TeanchplanConvert INSTANCE = Mappers.getMapper(TeanchplanConvert.class);

    // 将po转为dto数据
    @Mappings({
            @Mapping(source = "id", target = "teachPlanId"),
            @Mapping(source = "childrenNodes",target = "teachPlanTreeNodes")
    })
    TeachplanDTO node2dto(TeachplanNode node);

    //dto转po
    @Mapping(source = "teachPlanId",target = "id")
    Teachplan dto2entity(TeachplanDTO dto);

    //po转dto
    @Mapping(source = "id",target = "teachPlanId")
    TeachplanDTO entity2dto(Teachplan teachplan);

    //VO转dto
    TeachplanDTO vo2dto(TeachplanVO teachplanVO);


}
